Date: Mon, 16 Dec 1996 22:09:03 GMT
Server: NCSA/1.5
Content-type: text/html
Last-modified: Mon, 12 Feb 1996 13:43:12 GMT
Content-length: 6846


<html>
<head>
<title>
CS418 Lab 11
</title>
</head>


<body>
<h2> <!WA0><!WA0><!WA0><!WA0><!WA0><!WA0><!WA0><!WA0><img src="http://www.tc.cornell.edu/Visualization/Education/cs418/gifs/teapot.thumb.gif">
CS 418: Laboratory 11</h2> 
<h2> Implicit Surfaces</h2>
<b> Introduction. </b><p>
In this lab you will investigate implicit surface generation. Implicit surfaces
are generated by finding "level surfaces" in a 3D field. That is, by 
placing polygons in all of the voxels which have scalar data of a certain
value. The surface descriptions often take forms familar from analytical
geometry. For instance, a unit sphere at the origin is described by
<p> <code> x^2 + y^2 + z^2 - 1.0 </code> <p>
when a surface is fit to the points in 3D which have a value of zero.

<b><hr>Procedure</b>
<p>
Download:
<ul>
<li><!WA1><!WA1><!WA1><!WA1><!WA1><!WA1><!WA1><!WA1><a href="http://www.tc.cornell.edu/Visualization/Education/cs418/labs/heart.net"> heart.net </a>
<li><!WA2><!WA2><!WA2><!WA2><!WA2><!WA2><!WA2><!WA2><a href="http://www.tc.cornell.edu/Visualization/Education/cs418/labs/heart.cfg"> heart.cfg </a>
<p>
<li><!WA3><!WA3><!WA3><!WA3><!WA3><!WA3><!WA3><!WA3><a href="http://www.tc.cornell.edu/Visualization/Education/cs418/labs/SurfaceCombine.net">SurfaceCombine.net</a>
<li><!WA4><!WA4><!WA4><!WA4><!WA4><!WA4><!WA4><!WA4><a href="http://www.tc.cornell.edu/Visualization/Education/cs418/labs/SurfaceCombine.cfg">SurfaceCombine.cfg</a>
<p>
<li><!WA5><!WA5><!WA5><!WA5><!WA5><!WA5><!WA5><!WA5><a href="http://www.tc.cornell.edu/Visualization/Education/cs418/labs/blobbyMacroUI.net">blobbyMacroUI.net </a>
<li><!WA6><!WA6><!WA6><!WA6><!WA6><!WA6><!WA6><!WA6><a href="http://www.tc.cornell.edu/Visualization/Education/cs418/labs/blobbyMacroUI.cfg">blobbyMacroUI.cfg </a>
<p>
<li> Put the following in <code> ~yourID/.DXmacros </code> so than when DX
starts up it will find these macros. Note the programs in this exercise
<b> will not run </b> without these macros.
  <ul>
  <li><!WA7><!WA7><!WA7><!WA7><!WA7><!WA7><!WA7><!WA7><a href="http://www.tc.cornell.edu/Visualization/Education/cs418/labs/macros/InitCSGmacro.net">InitCSGmacro.net</a>
  <li><!WA8><!WA8><!WA8><!WA8><!WA8><!WA8><!WA8><!WA8><a href="http://www.tc.cornell.edu/Visualization/Education/cs418/labs/macros/MakeCSGsurfacemacro.net">MakeCSGsurfacemacro.net</a>
  <li><!WA9><!WA9><!WA9><!WA9><!WA9><!WA9><!WA9><!WA9><a href="http://www.tc.cornell.edu/Visualization/Education/cs418/labs/macros/UnionCSGmacro.net">UnionCSGmacro.net</a>
  <li><!WA10><!WA10><!WA10><!WA10><!WA10><!WA10><!WA10><!WA10><a href="http://www.tc.cornell.edu/Visualization/Education/cs418/labs/macros/blobbyMacro.net">blobbyMacro.net</a>
  </ul>
</ul>

<hr>
The program heart.net takes as input an implicit function of x,y,z and
forms an surface. The function is calculated at grid points, then
polygonalized by isosurface rendering, assuming
an isosurface value of zero. For example the formula
<p> <code> (2*x^2 + y^2 + z^2 -1)^3 - 0.2*x^2*z^3 - y^2*z^3
<p> </code> 
creates a heart-shaped object.
<p> <!WA11><!WA11><!WA11><!WA11><!WA11><!WA11><!WA11><!WA11><img src="http://www.tc.cornell.edu/Visualization/Education/cs418/labs/labgifs/lab11.heart.image.gif"> <p>
Different functions of x,y,z will produce different shapes. 
(Note that for different functions, you may
have to modify the range limits of the space defined by the Construct
module.) As an example, the following image was made by
defining an implicit sphere 
in a separate module from the heart, then morphing between them by 
linearly intropolating between the two 3D fields.
In this case, mixing .9 of the heart 3D field
with 0.1 of the sphere 3D field. The sphere used was:
<p> <code> x^2 + y^2 +(z+.25)^2 -.5 </code> <p>
<!WA12><!WA12><!WA12><!WA12><!WA12><!WA12><!WA12><!WA12><img src="http://www.tc.cornell.edu/Visualization/Education/cs418/labs/labgifs/lab11.heartsphere.image.gif"><p>

<hr>
The program SurfaceCombine.net shows how to combine two implicit surfaces
to simulate the "union" operation as used in constructive solid
geometry (see page 35 of Watt). Three new macros are used in this program;
InitCSG, UnionCSG, and MakeCSGsurface. You can inspect (or modify) the
macros using the "Open Selected Macro" option in the "Windows" menu of the
visual program editor.
The two cylinder surfaces are combined (in the UnionCSG macro)
using a <code> min(a,b) </code> function so that the voxels which are in the
interior of either cylinder are interior to the result. (Remember that
an implicit function changes sign as the surface is crossed and that for
the surfaces used here, that points inside have a negative value.) The
image below is the result of the union of two cylinders.
<p> <!WA13><!WA13><!WA13><!WA13><!WA13><!WA13><!WA13><!WA13><img src="http://www.tc.cornell.edu/Visualization/Education/cs418/labs/labgifs/lab11.cyls.image.gif"> <p>

<hr>
The program blobby.net computes an implicit surface based on spherical
fields of influence which can add together. See one of last year's 
<!WA14><!WA14><!WA14><!WA14><!WA14><!WA14><!WA14><!WA14><a href="http://www.tc.cornell.edu/Visualization/contrib/cs490-94to95/shuang/bm.html"> student
projects </a> for more information on blobby functions. The spherical
fields can have positive and negative field strengths. An example from
 blobby.net shows four positive spheres (transparent red) and two negative
spheres (blue) which when summed together, then passed thorough an
isosurface module produce the object shown to the right.
<p>
<!WA15><!WA15><!WA15><!WA15><!WA15><!WA15><!WA15><!WA15><img src="http://www.tc.cornell.edu/Visualization/Education/cs418/labs/labgifs/lab11.sphere.image.gif">
<!WA16><!WA16><!WA16><!WA16><!WA16><!WA16><!WA16><!WA16><img src="http://www.tc.cornell.edu/Visualization/Education/cs418/labs/labgifs/lab11.blobby.image.gif">
<hr>
<b> Assignment: </b> <p>
Execute the programs to understand their behavior, then modify them as
follows:

<ul>

<hr>
<li>Modify heart.net to generate a torus from an implicit function of
(x,y,z). You will need to construct a function
which is negative if the position (x,y,z) is within a certain distance
of a circle and positive otherwise. Include interactors to set the
radius of the torus and the radius of its cross-section.

<hr>
<li> Extend SurfaceCombine.net to perform the CSG operations of intersection
and subtraction by writing two new macros called IntersectCSG and SubCSG. 
Provide interactors for choosing any combination of two spheres, cylinders, tori,
or cones. Provide interactors for performing a union,
intersection, or subtraction of the two selected shapes. That is, your
program should be able to, for example, select a sphere and a cone, and
form the subtraction of cone-minus-sphere or sphere-minus-cone or union the sphere
and the cone or intersect the sphere and the cone. Shown below are the
intersection of two cylinders and one cylinder "minus" the other.
<p> <!WA17><!WA17><!WA17><!WA17><!WA17><!WA17><!WA17><!WA17><img src="http://www.tc.cornell.edu/Visualization/Education/cs418/labs/labgifs/lab11.cylsIntersect.image.gif"> 
 <!WA18><!WA18><!WA18><!WA18><!WA18><!WA18><!WA18><!WA18><img src="http://www.tc.cornell.edu/Visualization/Education/cs418/labs/labgifs/lab11.cylsMinus.image.gif"> <p>
The image below is formed as <p>
<code>((superquadric minus torus) union cylinder), </code><p>
but with about 1% white noise added to the 3D field. <p>  
 <!WA19><!WA19><!WA19><!WA19><!WA19><!WA19><!WA19><!WA19><img src="http://www.tc.cornell.edu/Visualization/Education/cs418/labs/labgifs/lab11.noisy.image.gif"> <p>

<hr>
<li> Use the interactors in blobby.net to make a human head with
recognizable (but not necessarily artistic) eyes, nose, mouth and
ears.<p>

<hr>
<li> Modify blobbyMacroUI.net to
produce two separate groups of blobs (with separate interactor inputs)
which can be combined using your CSG modules. You will need to modify
blobby.macro.net to output a 3D field rather than a surface. Show one
example of to separate blob groups combined with CSG operations.
</ul>

<hr>
Be prepared to demo the programs to show the torus generator, the CSG
operations, the head you designed, and the grouped blobby program. The
grader will exercise all interactors.
<p>

You should be able to explain your programs. You should use
transmitters/receivers, macros, and comments 
in the "Notation" field of each module
so that you and the grader can understand the program. 
Control panels, if any,
should be well organized, labeled, and with the appropriate numeric ranges.
<p>
The
<!WA20><!WA20><!WA20><!WA20><!WA20><!WA20><!WA20><!WA20><a href="http://www.tc.cornell.edu/Visualization/Education/cs418/GradeGuides/Lab11.grade.ps"> Lab 11 grading guide </a>
will be filled out by a consultant during section to evaluate your work.
<p>
<hr>
<!WA21><!WA21><!WA21><!WA21><!WA21><!WA21><!WA21><!WA21><img src="http://www.tc.cornell.edu/Visualization/Education/cs418/gifs/leftarrow.icon.gif">
Back to <!WA22><!WA22><!WA22><!WA22><!WA22><!WA22><!WA22><!WA22><a href="http://www.tc.cornell.edu/Visualization/Education/cs418/index.html">Main Page</a>
 <P>
<hr>
Last modified, 10/20/95, B. Land.
<! Revision history:
	Original document: Land 10/95
>
<br>
<!WA23><!WA23><!WA23><!WA23><!WA23><!WA23><!WA23><!WA23><IMG SRC="http://www.tc.cornell.edu/copyright.xbm">
<!WA24><!WA24><!WA24><!WA24><!WA24><!WA24><!WA24><!WA24><A HREF="http://www.tc.cornell.edu/ctcCopyright.html"> 
<i>Copyright Statement </I></A>
</body> </html>

